package com.ecoolex.hotel.saas.core;

import com.ecoolex.framework.cg.mybatis.MyBatisCodeGenerator;
import com.ecoolex.framework.cg.mybatis.core.ClassPluginInterface;
import com.ecoolex.framework.cg.mybatis.pojo.KeyValue;
import com.ecoolex.framework.cg.mybatis.support.DaoClassGenerate;
import com.ecoolex.framework.cg.mybatis.support.ManagerClassGenerate;
import org.junit.Test;

public class HotelSaasMyBatisCodegen {

	@SuppressWarnings("unchecked")
	@Test
	public void main() {
		// 配置项目路径
		MyBatisCodeGenerator generator = MyBatisCodeGenerator.create("src/main/java", "com.ecoolex.hotel.saas.core",
				KeyValue.create(ClassPluginInterface.TARGET_ENTITY, "com.ecoolex.hotel.saas.entity"),
				KeyValue.create(ClassPluginInterface.OVERRIDE, "false"));
		// 添加转移目录
		generator.addTransferPackage("com.ecoolex.hotel.saas.entity", "../hotel-saas-entity/");
		// 配置数据库
		generator.setJdbcConnection("com.mysql.jdbc.Driver",
				"jdbc:mysql://47.101.161.12:3306/template-hotel-saas?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull",
				"root", "Kcxx1245!", KeyValue.create("nullCatalogMeansCurrent", "true"));
		// 配置插件
		// 扩展dao插件
		generator.addPlugin(DaoClassGenerate.class);
		// 业务逻辑插件
		generator.addPlugin(ManagerClassGenerate.class);

		// 配置表
		// 自动增长主键模版
		// generator.createDefaultTable("member", "Member", "id");
		// 非自增长主键，自设主键模版
		// generator.createDefaultTable("user_info", "UserInfo");
		// 视图
//		generator.createView("user", "User");
		//品牌、商户、部门、营业点
		generator.createDefaultTable("store", "Store", "StoreId");
		generator.createDefaultTable("store_brand", "StoreBrand", "BrandId");
		generator.createDefaultTable("department", "Department", "DepartmentId");
		generator.createDefaultTable("outlets", "Outlets", "OutletsId");
		generator.createDefaultTable("department_outlets_joint", "DepartmentOutletsJoint", "Id");
		generator.createDefaultTable("store_weixin_config", "StoreWeixinConfig");
		generator.createDefaultTable("store_order_config", "StoreOrderConfig");
		generator.createDefaultTable("store_ad", "StoreAd", "AdId");
		generator.createDefaultTable("store_ad_position", "StoreAdPosition", "Id");
		generator.createDefaultTable("store_marketing", "StoreMarketing", "Id");
		//预售券、分销
		generator.createDefaultTable("distribution", "Distribution", "DistributionId");
		generator.createDefaultTable("presale_coupon", "PresaleCoupon", "PreCouponId");
		generator.createDefaultTable("presale_coupon_expirydate", "PresaleCouponExpirydate");
		generator.createDefaultTable("presale_coupon_distribtion", "PresaleCouponDistribtion", "Id");
		generator.createDefaultTable("presale_coupon_category", "PresaleCouponCategory", "CategoryId");
		generator.createDefaultTable("presale_coupon_category_joint", "PresaleCouponCategoryJoint", "Id");
		//预售券订单
		generator.createDefaultTable("presale_coupon_order", "PresaleCouponOrder", "OrderId");
		generator.createDefaultTable("presale_coupon_order_detail", "PresaleCouponOrderDetail", "DetailId");
		generator.createDefaultTable("presale_coupon_order_operate_record", "PresaleCouponOrderOperateRecord", "RecordId");
		generator.createDefaultTable("presale_coupon_order_after_sales", "PresaleCouponOrderAfterSales", "AfterSalesId");
		generator.createDefaultTable("presale_coupon_order_after_sales_record", "PresaleCouponOrderAfterSalesRecord", "RecordId");
		generator.createDefaultTable("payment_order", "PaymentOrder", "PaymentOrderId");
		generator.createDefaultTable("payment_order_record", "PaymentOrderRecord", "Id");
		//销售员/钱包
		generator.createDefaultTable("sales_user", "SalesUser");
		generator.createDefaultTable("sales_user_wallet", "SalesUserWallet", "WalletId");
		generator.createDefaultTable("sales_user_wallet_detail", "SalesUserWalletDetail", "DetailId");
		generator.createDefaultTable("sales_user_wallet_withdrawal_apply", "SalesUserWalletWithdrawalApply", "ApplyId");
		//商圈活动管理
		generator.createDefaultTable("activity", "Activity", "ActivityId");
		generator.createDefaultTable("activity_store", "ActivityStore", "Id");
		generator.createDefaultTable("activity_show_store", "ActivityShowStore", "Id");

		generator.generate();
	}
}
